import uvicorn
from fastapi import FastAPI, Body
from pydantic import BaseModel

app = FastAPI()

class Mp4Item(BaseModel):
    app: str
    file_name: str
    file_size: int
    folder: str
    start_time: int
    stream: str
    time_len: float
    url: str
    vhost: str
    mediaServerId: str


@app.get("/hk/getUrl")
async def get_url(id: str, streamType: int = 0):
    return {
        "code": "0",
        "msg": "success",
        "data": {
            "url": "rtsp://admin:cdtye123456@192.168.116.201:554/Streaming/Channels/103" if (int(id) % 2 == 0) else "rtsp://admin:cdtye123456@192.168.116.201:554/Streaming/Channels/103"
        }
    }


@app.post("/index/hook/on_record_mp4")
async def on_record_mp4(item: Mp4Item):

    print(item)

    return {
        "code": "0",
        "msg": "success"
    }


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=7002)
